/**
 * @Author：ming
 * @Date：2023/10/2 9:39 PM
 * @Filename：Hj8
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ming
 */
public class Hj22 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str ;
        while ((str=br.readLine())!=null){
            Integer n = Integer.valueOf(str);
            if(n!=0){
                int drink = drink(n);
                System.out.println(drink);
            }
        }
    }

    public static int drink(int n){
        if(n==2){
            return 1;
        }

        int count = 0;

        while (n>=3){
            count += n/3;
            n =  n/3+n-n/3*3;
        }

        if(n==2){
            count ++;
        }

        return count;
    }
}
